package com.mjlf.boot.service;

import com.mjlf.boot.thrift.idl.EventData;
import com.mjlf.boot.thrift.idl.EventService;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

/**
 * @ClassName ScreenControlClient
 * @Author mjlft
 * @Date 2020/3/6 17:24
 * @Version 1.0
 * @Description TODO
 */
public class ScreenControlClient {
    private static TTransport tTransport = null;
    private static TProtocol protocol = null;
    private static EventService.Client client = null;

    public static void connect(String host) throws Exception {
        tTransport = new TFramedTransport(new TSocket(host, 8899), 600);
        protocol = new TCompactProtocol(tTransport);
        client = new EventService.Client(protocol);
        tTransport.open();
    }

    public static void sendEvent(EventData eventData) throws Exception {
        client.doEvent(eventData);
    }
}
